<!--首先加载主题subject详细信息-->
<!--留言message信息-->
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>详情界面</title>
	<style type="text/css">
	  	body{
	  		*{margin: 0;padding: 0;}
	  	}
		#huifu{
			width: 65%;
			background-color: #ffffff;
			text-align: left;
			float: left;
			min-height: 500px;
		}
		#question{
			padding-left: 30px;
			background-color: #ffffff;
			margin-top: -20px;
			border-bottom: 3px solid #f2f2f2;
		}
		#question h1{
			background-color: #ffffff;
		}
		#names{
			background-color: #f2f2f2;
		}
		#name{
			color: green;
			font-weight: bold;
			margin-right: 10px;
			
		}
		#datas{
			font-size: 11px;
			background-color: #f2f2f2;
		}
		#content{
			color: black;
			font-size: 16px;
			margin-left: 20px;
		}
		#answers{
			margin-left: 10px;
			margin-right: 10px;
			padding: 10px;
			height: 70px;
			margin-bottom: 2px;
			background-color: #ffffff;
			border-bottom: 3px solid #f2f2f2;
		}
		#aleft{
			float: left;
			height: 50px;
			width: 20%;
		}
		#date{
			font-size: 11px;
		}
		#aright{
			float: left;
			height: 50px;
			width: 80%;
		}
		#forms{
			background-color: #ffffff;
			margin-left: 10px;
			margin-right: 10px;
			margin-top: 50px;
		}
		#forms textarea{
			margin: 0 auto;
			display: block;
			margin-top: 10px;
		}
		#submita{
			margin: 0 auto;
			display: block;
			margin-bottom: 30px;
		}
		#gonggaolianjie{
		
		background-color: #ffffff;
		float: left;
		width: 35%;
		min-height: 500px;
	}
	#gonggaolianjie h2{
		color: red;
	}
	#gonggaolian h2{
		float: left;
	}
	#gonggaolian a{
		float: right;
	    line-height: 70px;
	    margin-right: 50px;
	}
	#frame{
		border-top: 1px solid #4a5259;
		border-bottom: 1px solid #4a5259;
	}
	a{
		text-decoration: none;
		color: black;
	}
	a:hover{
		text-decoration: underline;
	}
	ul{
		list-style: none;
	}
	</style>
</head>
<body>
<?php
include_once("header.php");
?>
<div id="huifu">
<!--主题问题描述-->
<div id="question">
	<?php
	//获取subjectid
	if(isset($_GET["action"])&&$_GET["action"]=="show"&&isset($_GET["subjectid"])){
		$subjectid=$_GET["subjectid"];
	}else{
		$subjectid=0;//指定一个友好的错误新消息界面
	}
	//首先查询指定的主题信息
	$selectsubject="select * from subject where subjectid='$subjectid'";
	include_once("database.php");
	$result=mysql_query($selectsubject) or die("查询{$subjectid}主体信息失败:".mysql_error()."<br/>");
	if(mysql_num_rows($result)>0){
		$row=mysql_fetch_array($result);
		$title=$row["title"];
		$description=$row["description"];
		$questioner=$row["questioner"];
		$dates=$row["dates"];
		//下面把他们显示出来
		//注意定界符的书写方法
		echo <<<xqquestion
		<h1>{$title}</h1>
		<div id="names">
		<span id="name">{$questioner}</span><span id="datas">{$dates}</span>
		</div>
		<p id="content">{$description}</p>
xqquestion;
	}
	?>
</div>
<!--主题回复描述 加载回复信息-->
<?php
$selectanswers="select answerr,dates,description from answers where subjectid='$subjectid' order by dates desc";
@include_once("database.php");
$result=mysql_query($selectanswers) or die("{$subjectid}主题信息的回复加载失败:".mysql_error()."<br/>");
while($row=mysql_fetch_array($result,MYSQL_ASSOC)){
	$answer=$row["answerr"];
	$dates=$row["dates"];
	$description=$row["description"];
	//显示样式
	echo <<<showanswer
	<div id="answers">
	<div id="aleft">{$answer}<p id="date">{$dates}</p></div>
	<div id="aright"><p id="content">{$description}<p></div>
	</div>
showanswer;
}
?>
<!--回复输入框-->
<form action="" method="post" id="forms">
<textarea name="ans" rows="15" cols="70" placeholder="输入内容">
</textarea><br/>
<input type="submit" name="submit" value="提交回复" id="submita"><br/>
</form>
<?php
if(isset($_POST["submit"])&&$_POST["submit"]=="提交回复"){
	$description=$_POST["ans"];
	date_default_timezone_set("Asia/Shanghai");
	$dates=date("Y-m-d H:m:s");
	$answer=$_COOKIE["username"];//从cookie里获取当前登录用户的名字
	$insertintoanswer="insert into answers(subjectid,description,dates,answerr) values('$subjectid','$description','$dates','$answer')";
	@include_once("database.php");
	@mysql_query($insertintoanswer) or die("{$answer} 回复{$subjectid}失败了:".mysql_error()."<br/>");
	//插入就是成功
	//修改主题里的回复数
	$updatesubjectanswers="update subject set answers=answers+1 where subjectid='$subjectid'";
	@mysql_query($updatesubjectanswers) or die("修改{$subjectid}的回复数失败:".mysql_error()."<br/>");
	header("Location:xiangqing.php?action=show&subjectid={$subjectid}");
}
?>
</div>
<!--机房公告和友情链接-->
<div id="gonggaolianjie">
	<div id="gonggaolian">
		<h2>机房公告</h2>
		<?php 
		include_once("database.php");
		if(isset($_COOKIE["type"])&&$_COOKIE["type"]=="管理员") {
				echo '<a href="fabugonggao.php" >发布</a>';
			}
		?>
		

	</div>
	
	<iframe src="gonggao.php" name="iframe_main" id="frame" frameborder="0" width="100%" height="300">
		如果看到此处内容,则说明浏览器版本过低,升级浏览器即可!
	</iframe>
	<div id="gonggaolian">
	<h2>友情链接</h2>
	<?php 
		include_once("database.php");
		if(isset($_COOKIE["type"])&&$_COOKIE["type"]=="管理员") {
				echo '<a href="fabulink.php" >发布</a>';
			}
		?>
	</div>
	<iframe src="link.php" name="iframe_main" id="frame" frameborder="0" width="100%" height="300">
		如果看到此处内容,则说明浏览器版本过低,升级浏览器即可!
	</iframe>
</div>
<!--加载底部信息-->
<?php
include_once("footer.php");
?>
</body>
</html>